<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>供需对接服务系统--我的收藏</title>
	<!--公用样式-->
	<link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
	<link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/supplier/common/css/style.css"/>
	<!--Layui-->
	<link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
	<!--extended-->
	<link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
	<!--公用样式JS-->
	<script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
	<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
	<script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
</head>
<style>
	.Right {
		width: 100%;
		overflow-y: scroll;
	}

</style>

<body>
<!--头部-->

<!--容器-->
<div class="container clearfix">
	<!--右侧内容-->
	<div class="Right fr mt10">
		<div class="project whitebg">
			<table id="tableList" class="layui-hide" lay-filter="tableList"></table>
		</div>
	</div>
</div>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/tabs.js"></script>
<script type="text/html" id="toolBarRow">
	<a class="layui-btn layui-btn-xs  layui-btn-normal" lay-event="cancel" style="margin-left: 0px;">取消收藏</a>
</script>
<script type="text/javascript">
	var layer;
	var form = layui.form;
	var table = null;
	var tableIns = null;
	//注意进度条依赖 element 模块，否则无法进行正常渲染和功能性操作
	var element = "";
	layui.use('element', function () {
		element = layui.element;


	});
	layui.use('laydate', function () {
		var laydate = layui.laydate;
		//执行一个laydate实例
		laydate.render({
			elem: '#beginDate' //指定元素
		});
		laydate.render({
			elem: '#endDate' //指定元素
		});
	});

	layui.use('table', function () {
		table = layui.table;
		element = element;
		//方法级渲染
		tableIns = table.render({
			id: 'tableList',
			elem: '#tableList',
			height: 'auto',
			url: '/supplier/ruleCentre/selectCollect',
			cols: [[
				{
					title: '序号', width: '10%', templet: function (res) {
						return res.LAY_INDEX;
					}
				},
				{field: 'id', title: '编号', hide: true, sort: false},
				{field: 'projectId', title: '编号', hide: true, sort: false},
				{field: 'projectType', title: '项目类型', width: '15%', sort: false,templet: function (d) {
						var typestr=[];
						var type=d.projectType;
						if(type){
							if (type.indexOf("001")>-1) {
								typestr.push("监理");
							}
							if (type.indexOf("002")>-1) {
								typestr.push("咨询");
							}
							if (type.indexOf("003")>-1) {
								typestr.push("检测");
							}
							if (type.indexOf("100")>-1) {
								typestr.push("其他");
							}
							typestr=typestr.join(",");
						}
						return  typestr;

					}},
				{field: 'projectName', title: '项目名称', width: '30%', sort: false,templet:function (d) {
						return '<span class="cursor" onclick="showDetail(\'' + d.projectId + '\',\'' + d.projectName + '\',\'' + d.status + '\')">' + d.projectName + '</span>';
					}},
				{field: 'status', title: '项目状态', width: '15%', sort: false,templet: function (d) {
						if (d.status == "001") {
							return '<span class="pro_status" style="background-color:#2161e3;">已保存</span>';
						}
						if (d.status == "002") {
							return '<span class="pro_status" style="background-color:#2161e3;">待审核</span>';
						}
						if (d.status == "003") {
							return '<span class="pro_status" style="background-color:#2161e3;">已驳回</span>';
						}
						if (d.status == "004") {
							return '<span class="pro_status" style="background-color:#2161e3;">已结束</span>';
						}
						if (d.status == "005") {
							return '<span class="pro_status" style="background-color:#2161e3;">已撤销</span>';
						}
						if (d.status == "006") {
							return '<span class="pro_status" style="background-color:#2161e3;">已发布</span>'
						}
					}},
				{field: 'createDate', title: '发布时间', width: '15%', sort: true},
				{field: 'remark', title: '操作', width: '15%', toolbar: "#toolBarRow"}
			]],
			page: true,
			done: function (res, currentCount) {

			}
		});
		table.on('tool(tableList)', function (obj) {
			var data = obj.data;
			var id=data.id;
			layer.confirm('确定要取消收藏吗？', {
				btn: ['确定','关闭'] //按钮
			}, function(){
				layerAjax('/supplier/ruleCentre/deleteCollect',{id:id},'',function (d) {
					if(d.flag){
						layer.msg(d.msg, {icon: 6});
						setTimeout(function (){
							table.reload('tableList');
						},1000)
					}else{
						layer.msg(d.msg, {icon: 5});
						setTimeout(function (){
							table.reload('tableList');
						},1000)
					}
				})

			});

		});
	});
	function showDetail(id, projectName,status) {
		if(status=='005'){
			layer.msg('已经被撤回无法查看详情', {icon: 5});
		}else {
			window.parent._showtab('xm_v' + id, '查看-' +projectName, '/supplier/projectManager/projectDetail?type=v&supProjectId=' +id);
		}

	}
</script>
</body>

</html>
